package com.liangxy.news.model;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

/**
 * User entity for storing user data
 */
@Entity(tableName = "users")
public class User {
    
    @PrimaryKey
    @NonNull
    private String id;
    
    private String username;
    private String phone;
    private String password;
    private String avatar;
    private long lastLoginTime;
    
    @Ignore
    public User() {
        // Required empty constructor
    }
    
    public User(@NonNull String id, String username, String phone, String password, String avatar) {
        this.id = id;
        this.username = username;
        this.phone = phone;
        this.password = password;
        this.avatar = avatar;
        this.lastLoginTime = System.currentTimeMillis();
    }
    
    @Ignore
    public User(String phone, String password) {
        this.id = String.valueOf(System.currentTimeMillis());
        this.username = "User_" + phone.substring(Math.max(0, phone.length() - 4));
        this.phone = phone;
        this.password = password;
        this.avatar = "";
        this.lastLoginTime = System.currentTimeMillis();
    }
    
    @NonNull
    public String getId() {
        return id;
    }
    
    public void setId(@NonNull String id) {
        this.id = id;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
    
    public String getAvatar() {
        return avatar;
    }
    
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
    
    public long getLastLoginTime() {
        return lastLoginTime;
    }
    
    public void setLastLoginTime(long lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }
} 